package com.yiqi.liebang.feature.home.view.adapter;

import android.graphics.Paint;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.suozhang.framework.framework.AM;
import com.yiqi.liebang.R;
import com.yiqi.liebang.common.widget.RatingBar;
import com.yiqi.liebang.entity.bo.QuestionBo;
import com.yiqi.liebang.entity.bo.TopicBo;

public class TopicAdapter extends BaseQuickAdapter<TopicBo,BaseViewHolder> {
    public TopicAdapter() {
        super(R.layout.item_home_topic);
    }

    @Override
    protected void convert(BaseViewHolder helper, TopicBo item) {
        TextView textView=helper.getView(R.id.tv_user_topic_prize_yuan);


        textView.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );
        helper.setText(R.id.tv_user_topic_title, item.getTopicName())
                .setText(R.id.tv_user_topic_num, "帮助过" + item.getUserAccountFormMap().getHelpNum() + "人")
                .setText(R.id.tv_user_topic_time, item.getServiceTime() + "小时/次")
                .setText(R.id.tv_user_topic_prize, item.getTopicPrice() + "")
                .setText(R.id.tv_user_topic_prize_yuan, item.getOriginalPrice() + "元/次")
                .setText(R.id.tv_user_topic_name, item.getUserAccountFormMap().getUserName() + "")
                .setText(R.id.tv_user_topic_position,item.getUserAccountFormMap().getPosition())
                .addOnClickListener(R.id.iv_user_topic)
                .addOnClickListener(R.id.iv_user_position)
                .addOnClickListener(R.id.iv_user_certification)

                .setText(R.id.tv_user_topic_type, item.getServiceType() == 0 ? "线下约见" : "全国通话")
                .setBackgroundRes(R.id.tv_user_topic_type, item.getServiceType() == 0 ? R.drawable.list_button_xianxia : R.drawable.list_button_quanguo)
        ;
        if (!TextUtils.isEmpty(item.getUserAccountFormMap().getCompany())||!TextUtils.isEmpty(item.getUserAccountFormMap().getPosition())) {
            helper.getView(R.id.view_line).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.view_line).setVisibility(View.GONE);
        }
        RatingBar ratingBar = helper.getView(R.id.rb_user_topic_star);
        ratingBar.setStar(item.getStartLevel());
        AM.image().bindToCircleObject(item.getUserAccountFormMap().getUserHead(),helper.getView(R.id.iv_user_topic));
        if (item.getUserAccountFormMap().getIsOccupation()==1){
            helper.getView(R.id.iv_user_position).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.iv_user_position).setVisibility(View.GONE);
        }
        if (item.getUserAccountFormMap().getIsBasic()==1){
            helper.getView(R.id.iv_user_certification).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.iv_user_certification).setVisibility(View.GONE);
        }
    }
}
